import instance from "@/utils/http.js";
import Api from "@/api/index.js";

//获取用户列表
export const getUserLoadDataList = (PageNo,PageSize,userRole,username) => {
    return instance({
        url: Api.user_loadDataList,
        method: 'post',
        data: {
            PageNo: PageNo || 1,
            PageSize: PageSize || 15,
            userRole: userRole,
            username
        }
    })
}

//修改用户信息
export const PostUserUpdate = data => {
    return instance({
        url: Api.user_update,
        method: 'post',
        data: {
            avatarUrl: data.avatarUrl,
            email: data.email,
            lastLogin: data.lastLogin,
            phone: data.phone,
            remark: data.remark,
            userRole: data.userRole,
            userStatus: data.userStatus,
            username: data.username,
            userId: data.userId,
            password: data.password
        }
    })
}

//添加用户
export const PostUserAdd = data => {
    return instance({
        url: Api.user_add,
        method: 'post',
        data: {
            avatarUrl: data.avatarUrl,
            email: data.email,
            lastLogin: data.lastLogin,
            phone: data.phone,
            remark: data.remark,
            userRole: data.userRole,
            userStatus: data.userStatus,
            username: data.username,
            password: data.password
        }
    })
}

//修改当前登录的用户密码
export const updateRePassword = (data) => {
    return instance({
        url: Api.updatePassword,
        method: 'post',
        data: {
            avatarUrl: data.avatarUrl,
            username: data.username,
            email: data.email,
            phone: data.phone,
            password: data.password,
            repPassword: data.newPassword
        }
    })
}

//删除用户
export const PostUserDelete = (id) => {
    return instance({
        url: Api.user_delete,
        method: 'post',
        data: {
            id
        }
    })
}